package day7

import (
	"fmt"
	"io/ioutil"
	"os"
)

func Start(path string, pp map[string][]string) {

	info, err := os.Stat(path)
	if err != nil {
		fmt.Println("出错 ", err)
	}

	if info.IsDir() {
		cc, _ := ioutil.ReadDir(path)
		for _, v := range cc {
			if v.IsDir() {
				tp := path + "/" + v.Name()
				set(path, tp, pp)
				Start(tp, pp)
			}
		}
	} else {
		set(path, path+"/"+info.Name(), pp)
	}
}

func set(key string, val string, pp map[string][]string) {
	var tmpVal []string = pp[key]
	if tmpVal == nil {
		pp[key] = []string{val}
	} else {
		pp[key] = append(tmpVal, val)
	}
}
